/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TMyCashCard;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TMyCashCardDao;
import com.ruipengkj.service.TMyCashCardService;
/**
 * 说明：
 * 商品库存Service层接口实现
 * @Author：李智深
 * @Date：2012-03-16
 */
@Service
public class TMyCashCardServiceImpl implements TMyCashCardService{
	@Resource
	private TMyCashCardDao TMyCashCardDao;//DAO层
	
	//查询所有
	@Override
	public List<TMyCashCard> findService(TMyCashCard entity) throws Exception {
		String hql = "select o from TMyCashCard o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TMyCashCardDao.findDao(hql, whereHQL.toString(), param, orderby);
	}

	//根据ID翻页查询
	@Override
	public PageModel<TMyCashCard> getScrollService(int firstResult,
			int maxResult, TMyCashCard entity) throws Exception {
		String hql = "select o from TMyCashCard o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TMyCashCardDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}

	//修改
	@Override
	public void modifyService(TMyCashCard entity) throws Exception {
		TMyCashCardDao.modifyDao(entity);
		
	}
	//添加
	@Override
	public void saveService(TMyCashCard entity) throws Exception {
		TMyCashCardDao.saveDao(entity);
	}
	//根据ID删除
	@Override
	public void deleteService(String id) throws Exception {
		TMyCashCardDao.deleteDao(id);
		
	}
	//根据ID查询
	@Override
	public TMyCashCard getByIdService(String id) throws Exception {
		return TMyCashCardDao.getByIdDao(id);
	}
	//添加或修改
	@Override
	public void saveOrUpdateService(TMyCashCard entity) throws Exception {
		TMyCashCardDao.saveOrUpdateDao(entity);
	}
	//添加返回ID
	@Override
	public Serializable saveRetService(TMyCashCard entity) throws Exception {
		return TMyCashCardDao.saveRetDao(entity);
	}
	public TMyCashCardDao getTMyCashCardDao() {
		return TMyCashCardDao;
	}

	public void setTMyCashCardDao(TMyCashCardDao TMyCashCardDao) {
		this.TMyCashCardDao = TMyCashCardDao;
	}
}